21 #define F_USING_MAG 0x0002 // normally should be defined in build.h 27 #define MAGBUFFSIZEX 14 28 #define MAGBUFFSIZEY (2 * MAGBUFFSIZEX)
29 #define MINMEASUREMENTS4CAL 110
30 #define MINMEASUREMENTS7CAL 220
31 #define MINMEASUREMENTS10CAL 330
32 #define MAXMEASUREMENTS 360
33 #define CAL_INTERVAL_SECS 300
34 #define MINBFITUT 10.0F
35 #define MAXBFITUT 90.0F
36 #define FITERRORAGINGSECS 86400.0F
37 #define MESHDELTACOUNTS 50
38 #define DEFAULTB 50.0F
108 #else // if F_USING_MAG 119 #endif // if F_USING_MAG 120 #endif // #ifndef MAGNETIC_H float ftrB
trial value of geomagnetic field magnitude in uT
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
void fUpdateMagCalibration10(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
float fBSq
square of fB (uT^2)
#define MAGBUFFSIZEY
y dimension in magnetometer buffer (12x24 equals 288 elements)
int32_t iValidMagCal
solver used: 0 (no calibration) or 4, 7, 10 element
int32_t itimeslice
counter for tine slicing magnetic calibration calculations
int32_t index[MAGBUFFSIZEX][MAGBUFFSIZEY]
array of time indices
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
int8_t iMagBufferReadOnly
flag to denote that the magnetic measurement buffer is temporarily read only
float fYTY
Y^T.Y for 4 element calibration = (iB^2)^2.
int8_t iCalInProgress
flag denoting that a calibration is in progress
float ftrFitErrorpc
trial value of fit error %
int16_t iBs[3][MAGBUFFSIZEX][MAGBUFFSIZEY]
uncalibrated magnetometer readings
void fUpdateMagCalibration7(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
void iUpdateMagBuffer(struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag, int32_t loopcounter)
int8_t iInitiateMagCal
flag to start a new magnetic calibration
void fUpdateMagCalibration4(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
int8_t iNewCalibrationAvailable
flag denoting that a new calibration has been computed
void fUpdateMagCalibration7Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
int8_t i7ElementSolverTried
flag to denote at least one attempt made with 4 element calibration
void fUpdateMagCalibration4Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
void fInitializeMagCalibration(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer)
float fB
current geomagnetic field magnitude (uT)
#define MAGBUFFSIZEX
x dimension in magnetometer buffer (12x24 equals 288 elements)
void fUpdateMagCalibration10Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
int8_t i4ElementSolverTried
flag to denote at least one attempt made with 4 element calibration
float fFitErrorpc
current fit error %
int8_t i10ElementSolverTried
flag to denote at least one attempt made with 4 element calibration
void fRunMagCalibration(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag, int32_t loopcounter)
int16_t tanarray[MAGBUFFSIZEX - 1]
array of tangents of (100 * angle)
int16_t iMagBufferCount
number of magnetometer readings
Magnetic Calibration Structure.
void fInvertMagCal(struct MagSensor *pthisMag, struct MagCalibration *pthisMagCal)